package socket2redis;

import java.io.IOException;

/**
 * @author fangjiaxiaobai@gmail.com[公众号：方家小白]
 * @date 2020-06-24 17:23
 * @since 1.0.0
 */
public class RedisDemo {

    public static void main(String[] args) throws IOException {

        String host = "10.1.14.159";
        int port = 6379;

        SocketRedisClient client = new SocketRedisClient(host, port);
        String authCmd = client.exec("auth moyang");
        System.out.println("登录验证结果:" + authCmd);
        System.out.println("删除已经存在的key :" + client.exec("del k97"));
        for (int i = 1; i <= 10000; i++) {
            String cmd = "pfadd k97 " + i;
            client.exec(cmd);

            String cmd2 = "pfcount k97 ";
            String exec = client.exec(cmd2);
            System.out.println("执行命令:" + cmd + " 返回结果:" + exec); // 返回的结果是未解析Redis协议的。
        }
        client.releases();
    }


}
